<!DOCTYPE html>
<html>
<head>
	<title>待办任务查询</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <script type="text/javascript">
        var path = window.document.location.href;
        var pathName = window.document.location.pathname;
        var hostPath = path.substring(0, path.indexOf(pathName));
        var projectName = pathName.substring(0, pathName.substr(1).indexOf("/") + 1);
        document.write('<scr' + 'ipt src="' + projectName + '/js/html/header.js"></scr'+'ipt>');
    </script>
</head>
<body>
	<table id="dg" style="width: auto; height: auto" fitColumns="true">
		<thead>
			<tr>
				<th field="taskId" align="right" width="100" 
					data-options="
					sortable:true,
					remoteSort:false
					">任务ID</th>
				<th field="handlerNode" align="right" width="100"
					data-options="
					sortable:true,
					remoteSort:false
					">办理节点</th>
				<th field="handlerName" align="right" width="100" 
					data-options="
					sortable:true,
					remoteSort:false
					">办理人名称</th>
				<th field="result" align="right" width="100" 
					data-options="
					sortable:true,
					remoteSort:false
					">审批结果</th>
				<th field="comments" align="right" width="100" 
					data-options="
					sortable:true,
					remoteSort:false
					">审批意见</th>
				<th field="startTime" align="right" width="100" 
					data-options="
					sortable:true,
					remoteSort:false
					">开始时间</th>
				<th field="endTime" align="right" width="100" 
					data-options="
					sortable:true,
					remoteSort:false
					">结束时间</th>
			</tr>
		</thead>
	</table>
	<!--隐藏的文本框-->
	<div id="win" class="easyui-window" title="工作流任务" style="width: 800px; height: 450px" closed="true" data-options="iconCls:'icon-save',modal:true">
		<div id="centers" data-options="region:'center',title:'center title'" style="padding: 5px; background: #eee; height: 90%"></div>
	</div>
	
	<img id="ImagePic"  style="width: auto; height: auto" />


	<script>
		$(function () {
			var taskId = getParam('taskId');
			var procInstId = getParam('procInstId');
			$.messager.progress();
			//意见列表
			commentsList(procInstId,taskId)
			//流程图
			display(taskId)
		});
		
		function commentsList(procInstId,taskId) {
			$('#dg').datagrid({
		        method: 'post',
		        title:'审批意见',
		        striped: true,
		        nowrap: true,
		        border: true,
		        idField: 'id',
		        singleSelect: true,
		        rownumbers: true,
		        fit: false,
		        fitColumns: true,
		        loadMsg: '数据加载中……',
		        queryParams:{
		        	"taskId":taskId,
		        	"procInstId":procInstId
				},
		        loader: function(param, success, error) {
					$.ajax({
						type: "POST",
					    url: projectName + "/workflow/task/list/comments",
					    data: JSON.stringify(param),
					    dataType: "json",
		                contentType : "application/json;charset=utf-8",
					    success: function(data) {
					    	$.messager.progress("close");
		                    if (!data.success) {
		                        $.messager.alert("错误提示", '[' + data.code + ']' + data.message);
		                        return;
		                    }
					        success(data);
					    },
					    error: function (err, status) {
		                    $.messager.progress("close");
		                	$.messager.alert("错误提示", '[' + err.status + ']' + err.responseText);
		                	$('#dg').datagrid('loaded');
		                }
					});
		        }
		    });
		}
		
		function display(taskId) {
			$.ajax({
				type : "POST",
				url : projectName + "/workflow/process/display",
				data : JSON.stringify({
					'id' : taskId
				}),
				dataType : "json",
				contentType : "application/json;charset=utf-8",
				success : function(result) {
					if (result.success) {
						$("#ImagePic").attr("src","data:image/gif;base64," + result.entity);
	                } else {
	                	if(!jQuery.isEmptyObject(result.message)){
	                		$.messager.alert("系统错误", result.message);
	                	}else{
	                		$.messager.alert("系统错误", result);
	                	}
	                    return;
	                }
				},
                error: function (err, status) {
                    errorMsgAlert(err);
                }
			});
		}
		
		//获取URL参数
		function getParam(name) {
			var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
			var r = window.location.search.substr(1).match(reg);
			if (r != null){
				return decodeURI(r[2]);
			}
			return null;
		}
		
	</script>
</body>
</html>

